package com.REPDPMSystem.Service.Handler;

import com.REPDPMSystem.Service.DeleteService;
import com.REPDPMSystem.Entity.Folder;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class DeleteHandler implements DeleteService {
    @Autowired
    private FileHandler fileHandler;
    @Autowired
    private FolderHandler folderHandler;
    @Override
    //递归删除
    public boolean deleteFolder(String folderId){
        List<Folder> flist=folderHandler.getFolderByParentFolderId(folderId);
        //不为空
        if(!flist.isEmpty()){
            for(Folder i:flist)
                deleteFolder(i.getFolder_id());
        }
        //先删文件夹中的文件，再删该文件夹

        return fileHandler.deleteFileByFolderId(folderId) && folderHandler.deleteFolderByFolderId(folderId);
    }
}
